package main

import "fmt"

type ListNode struct {
	Val  int
	Next *ListNode
}

func isPalindrome(head *ListNode) bool {
	temp := head
	arr := []int{}
	for {
		if temp != nil {
			arr = append(arr, temp.Val)
			temp = temp.Next
		} else {
			break
		}
	}

	for i, j := 0, len(arr)-1; i < j; i, j = i+1, j-1 {
		arr[i], arr[j] = arr[j], arr[i]
	}
	temp = head
	for i := 0; i < len(arr); i++ {
		if temp.Val != arr[i] {
			return false
		}
		temp = temp.Next
	}
	return true
}
func main() {
	node1 := &ListNode{1, nil}
	node2 := &ListNode{2, nil}
	node1.Next = node2
	fmt.Println(isPalindrome(node1))
}
